function [dat]=r_bats(parameter)
% ---- Read BATS parameter

dirBATS='/calcul/pc-charria/OBSERVATIONS/MOORINGS/BATS/';

% ---- Create the Structure ...        
dat = struct('dummy',1);
 

if (strcmp(parameter,'T'))
    load([dirBATS,'BATS_T_S.mat'])
    dat.data=new_tmp;
    dat.depthdata=new_depth; 
    dat.timedata=new_date; %decy
    load([dirBATS,'733751.5681ctd.mat'])
    dat.londata=median(data(:,4));
    dat.latdata=median(data(:,3));
elseif (strcmp(parameter,'S'))
    load([dirBATS,'BATS_T_S.mat'])
    dat.data=new_sal;
    dat.depthdata=new_depth; 
    dat.timedata=new_date; %decy
    load([dirBATS,'733751.5681ctd.mat'])
    dat.londata=median(data(:,4));
    dat.latdata=median(data(:,3)); 
elseif (strcmp(parameter,'NO3'))
    load([dirBATS,'BATS_NO3.mat'])    
    dat.data=new_NO3;
    dat.depthdata=prof_no3; 
    dat.timedata=date_dec_no3; %decy
    load([dirBATS,'733757.2909bot.mat'])
    dat.londata=data(:,7);
    dat.latdata=data(:,5); 
elseif (strcmp(parameter,'CHL'))    
    load([dirBATS,'BATS_CHL.mat'])  
    dat.data=Chl;
    dat.depthdata=prof; 
    dat.timedata=date_dec; % decy
    load([dirBATS,'733757.2909bot.mat'])
    dat.londata=data(:,7);
    dat.latdata=data(:,5);  
elseif (strcmp(parameter,'PON')) 
    load([dirBATS,'BATS_PON.mat'])     
    dat.data=PON_last;
    dat.depthdata=prof_last; 
    dat.timedata=date_last; % decy
    load([dirBATS,'733757.2909bot.mat'])
    dat.londata=data(:,7);
    dat.latdata=data(:,5);    
elseif (strcmp(parameter,'DON'))
    load([dirBATS,'BATS_DON.mat'])     
    dat.data=new_DON;
    dat.depthdata=prof_don; 
    dat.timedata=date_dec_don; % decy
    load([dirBATS,'733757.2909bot.mat'])
    dat.londata=data(:,7);
    dat.latdata=data(:,5);     
    % Soustraction du DON refractaire:
    % moyenne concentrations DON supérieur a 3500m = 2.5542
    dat.data=dat.data-2.5542;
elseif (strcmp(parameter,'PP'))
    disp('Not implemented !')
    return
    dat.data=data(:,8); %
    dat.depthdata=data(:,2); 
    dat.timedata=data(:,5); % decy
    load([dirBATS,'733751.5697prod.mat'])
    dat.londata=data(:,7);
    dat.latdata=data(:,6);  
end
   
% In file: 733445.5322prod.mat
%
% Cruise
% Cruise ID
% 	
% Dep1
% Depth (m)
% 	
% Decyr
% Decimal Year
% 	
% Lat
% Latitude (° N)
% 	
% Long
% Longitude (° W)
%
% PP
% 14C Primary Production
% (mgC/m^3/day)
	

% ---------- SPECIFIC for BATS station ----------------------
% ---- Bug correction in lon/lat data


dat.londata=median(dat.londata);
dat.latdata=median(dat.latdata);

% ind1=find(dat.londata < 1);
% ind2=find(dat.latdata < 1);
% dat.londata(ind1)=NaN;
% dat.latdata(ind2)=NaN;
% X=find(~isnan(dat.londata));
% dat.londata=interp1(X,dat.londata(X),1:length(dat.londata));
% Y=find(~isnan(dat.latdata));
% dat.latdata=interp1(Y,dat.latdata(Y),1:length(dat.latdata));

% --- Convert into eastern longitudes
dat.londata=-dat.londata;
% ------------------------------------------------------------


% A way of going from decimal year to yy,mm,dd,hr,mn,sec
%[Y,MO,D,H,MI,S]=datevec(datenum(fix(decy),1,1)+((decy-fix(decy))*(datenum(fix(decy),12,31)-datenum(fix(decy),1,1)+1)))

% From decimal year to MATLAB Serial number date
dat.timedata=datenum(fix(dat.timedata),1,1)+...
    ((dat.timedata-fix(dat.timedata)).*(datenum(fix(dat.timedata),12,31)...
    -datenum(fix(dat.timedata),1,1)+1));



% ---- Clean the Structure ...
dat=rmfield(dat,'dummy');    